﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Interactivity;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Mandarine.Behavior
{
    /// <summary>
    /// 「戻る」ナビゲーションの最新エントリに戻るアクションを提供するアクションクラス
    /// </summary>
	public class BackAction : TriggerAction<DependencyObject>
	{
	    protected override void Invoke(object parameter)
	    {
            var frame = Application.Current.RootVisual as Frame;

            if (frame == null)
            {
                throw new NotSupportedException();
            }

            if (frame.CanGoBack)
            {
                frame.GoBack();
            }
        }
	}
}
